package com.mad.gdrapps;

import java.io.InputStream;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class AboutGuruScr extends Activity implements Constants{


	public void onCreate(Bundle savedInstance){
		super.onCreate(savedInstance);
		setContentView(R.layout.aboutguru);
		
		  try {
			   
	            Log.d("BANGLA", "Reading text file now");
	            InputStream fis2 = this.getAssets().open("aboutguru");

	    		 // asset can't be more than 2 gigs.
	            int size = fis2.available();

	            byte[] buffer = new byte[size];
	            fis2.read(buffer);
	            fis2.close();
	            
	            String fullContent = new String(buffer);
	            
	            Log.d("BANGLA","size of input tsream="+size);
	            Log.d("BANGLA","full content="+fullContent);
	            
	            
	            TextView aboutGuruTV = (TextView)findViewById(R.id.aboutGuruTV);
	    		aboutGuruTV.setText(fullContent);
	    		
	    		setButtonListener((ImageButton)findViewById(R.id.guru_auregzebBtn),"aurangzeb","Ram Rai and Aurangzeb");
	    		setButtonListener((ImageButton)findViewById(R.id.guru_babaBtn),"bababakala","Baba Bakala");
	    		setButtonListener((ImageButton)findViewById(R.id.guru_brahminBtn),"jealousbrahmin","The Jealous Brahmin");
	    		setButtonListener((ImageButton)findViewById(R.id.guru_queenBtn),"queen","Identifying the queen");
	    		setButtonListener((ImageButton)findViewById(R.id.guru_smallpoxBtn),"smallpox","Smallpox in Delhi");
	    		
	    		
	    		ImageView glrBtn = (ImageView) findViewById(R.id.guru_galleryBtn);
	    		glrBtn.setOnClickListener(new Button.OnClickListener() {
	              	
	              	public void onClick(View v){
	          			Intent intent = new Intent(getApplicationContext(), GalleryGdrScr.class);
	    	        	startActivity(intent);
	              	}
	              	
	              });
	    		
	    	} catch (Exception e) {
				e.printStackTrace();
			}
	    	
		//Helper help = new Helper();
		//help.loadProperties();
		
	}
	

	private void setButtonListener( ImageButton imgBtn, final String contentFileName, final String title){
		  
		imgBtn.setOnClickListener(new Button.OnClickListener() {
          	
          	public void onClick(View v){
          		
      			Intent intent = new Intent(getApplicationContext(), DisplayTextOnlyScr.class);
	        		Bundle b = new Bundle(1);
	        		b.putString(KEY_CONTENT_FILE_NAME, contentFileName);
	        		b.putString(KEY_CONTENT_TITLE, title);
	        		
	        		intent.putExtra(KEY_CONTENT_BUNDLE,b);
	        		startActivity(intent);
	        		
          	}
          });
	}
	
}
